home *** CD-ROM | disk | FTP | other *** search
- #include "about MSG.h"
- #include "styled text.h"
-
- /*-----------------------------------------------------------------------------------*/
- /* internal stuff for about MSG.c */
-
- static void SetupTheAboutMSGWindow(WindowDataHandle theData);
- static void ShutdownTheAboutMSGWindow(WindowDataHandle theData);
- static void OpenTheMSGWindow(WindowDataHandle theData);
- static void DrawTheAboutMSGWindow(WindowDataHandle theData);
- static void DoTheMSGThing(WindowDataHandle theData);
- static void AboutMSGEventLoop(WindowDataHandle theData);
-
- static PicHandle gAboutPict=0L;
- static CharHandle gAboutText=0L;
- static StylHandle gAboutStyle=0L;
-
- static Ptr gOffscreenBitMap=0L;
- static GrafPort gOffscreenGrafPort;
- static GrafPtr gOffscreenGrafPtr=0L;
-
- #define MAX_OFFSCREEN_LINES 5
- #define kOffscreenWidth 130
- #define kOffscreenHeight ((MAX_OFFSCREEN_LINES*12)+1)
- #define RIGHT_SLOP 13
- #define TOP_SLOP 29
-
- #define kAboutTextID 150
-
- short AboutMSGBoxDispatch(WindowDataHandle theData, short theMessage, unsigned long misc)
- {
- switch (theMessage) /* see graphics.h for list of messages*/
- {
- case kUpdate:
- DrawTheAboutMSGWindow(theData);
- return kSuccess;
- case kOpen:
- OpenTheMSGWindow(theData);
- return kSuccess;
- case kStartup:
- SetupTheAboutMSGWindow(theData);
- return kSuccess;
- case kShutdown:
- ShutdownTheAboutMSGWindow(theData);
- return kSuccess;
- case kChangeDepth:
- gAboutPict=ReleaseThePict(gAboutPict);
- return kSuccess;
- }
-
- return kFailure; /* for all other messages, defer to default processing */
- }
-
- void SetupTheAboutMSGWindow(WindowDataHandle theData)
- {
- long offRowBytes, sizeOfOff;
-
- (**theData).windowWidth=324;
- (**theData).windowHeight=199;
- (**theData).windowType=plainDBox;
- (**theData).windowTitle[0]=0x00; /* null title, never shown */
- (**theData).hasCloseBox=FALSE;
- (**theData).maxDepth=8;
- gAboutText=(CharHandle)GetResource('TEXT', kAboutTextID);
- gAboutStyle=(StylHandle)GetResource('styl', kAboutTextID);
-
- gOffscreenGrafPtr=&gOffscreenGrafPort;
- OpenPort(&gOffscreenGrafPort); /* make a new port */
-
- /* calculate the size of the offscreen bitmap from the boundsrect */
- offRowBytes=(((**theData).windowWidth+15)>>4)<<1;
- sizeOfOff=(long)((**theData).windowHeight)*offRowBytes;
-
- gOffscreenBitMap=NewPtr(sizeOfOff); /* allocate space for bitmap */
- if (gOffscreenBitMap==0L) /* abort if unsuccessful */
- Debugger();
-
- gOffscreenGrafPort.portBits.baseAddr=gOffscreenBitMap; /* --> our bitmap */
- gOffscreenGrafPort.portBits.rowBytes=offRowBytes; /* bitmap size */
- SetRect(&gOffscreenGrafPort.portBits.bounds, 0, 0, kOffscreenWidth, kOffscreenHeight);
- gOffscreenGrafPort.portRect=gOffscreenGrafPort.portBits.bounds;
-
- SetPort(gOffscreenGrafPtr);
- }
-
- void ShutdownTheAboutMSGWindow(WindowDataHandle theData)
- {
- gAboutPict=ReleaseThePict(gAboutPict);
- if (gOffscreenBitMap!=0L)
- {
- DisposePtr(gOffscreenBitMap);
- ClosePort(&gOffscreenGrafPort);
- }
- }
-
- void OpenTheMSGWindow(WindowDataHandle theData)
- {
- UpdateTheWindow((ExtendedWindowDataHandle)theData);
- AboutMSGEventLoop(theData);
- }
-
- void AboutMSGEventLoop(WindowDataHandle theData)
- {
- GrafPtr oldPort;
- GrafPtr curPort;
- short startLine, numLines;
- short i;
- Rect sourceRect, destRect;
- Rect mirrorSourceRect, mirrorDestRect;
- Rect newSourceRect, newDestRect;
- long dummy;
- RgnHandle scrollRgn;
- Rect ovalRect;
- Boolean notDoneYet;
-
- GetPort(&oldPort);
- SetPort(curPort=GetWindowPtr(theData));
- startLine=0;
- numLines=CountLines(gAboutText, gAboutStyle, kCenter, srcXor, gOffscreenGrafPort.portRect);
- SetRect(&sourceRect, curPort->portRect.right-RIGHT_SLOP-kOffscreenWidth,
- TOP_SLOP, curPort->portRect.right-RIGHT_SLOP,
- (curPort->portRect.bottom-curPort->portRect.top)/2);
- OffsetRect(&sourceRect, 0, 1);
- destRect=sourceRect;
- OffsetRect(&destRect, 0, -1);
- mirrorSourceRect=sourceRect;
- mirrorSourceRect.top=sourceRect.bottom-1;
- mirrorSourceRect.bottom=sourceRect.bottom-sourceRect.top+mirrorSourceRect.top;
- mirrorDestRect=mirrorSourceRect;
- OffsetRect(&mirrorDestRect, 0, 1);
- newDestRect=sourceRect;
- newDestRect.top=newDestRect.bottom-1;
- SetRect(&ovalRect, 173, 28, 315, 171);
- scrollRgn=NewRgn();
- OpenRgn();
- FrameOval(&ovalRect);
- CloseRgn(scrollRgn);
- notDoneYet=TRUE;
-
- while (notDoneYet)
- {
- SetPort(gOffscreenGrafPtr);
- FillRect(&(gOffscreenGrafPtr->portRect), &qd.black);
- DrawThePartialText(gAboutText, gAboutStyle, kCenter, srcXor, gOffscreenGrafPort.portRect,
- startLine, startLine+MAX_OFFSCREEN_LINES+1);
- SetPort(curPort);
-
- newSourceRect.top=newSourceRect.left=0;
- newSourceRect.right=kOffscreenWidth;
- newSourceRect.bottom=1;
- for (i=0; ((i<kOffscreenHeight) && ((notDoneYet=(!Button()))==TRUE)); i++)
- {
- CopyBits(&(curPort->portBits), &(curPort->portBits), &sourceRect, &destRect, 0,
- scrollRgn);
- CopyBits(&(curPort->portBits), &(curPort->portBits), &mirrorSourceRect,
- &mirrorDestRect, 0, scrollRgn);
- CopyBits(&(gOffscreenGrafPort.portBits), &(curPort->portBits), &newSourceRect,
- &newDestRect, 0, 0L);
- newSourceRect.top++;
- newSourceRect.bottom++;
- Delay(7, &dummy);
- }
-
- startLine+=MAX_OFFSCREEN_LINES;
- if (startLine>numLines)
- startLine=0;
- }
-
- DisposeRgn(scrollRgn);
- SetPort(oldPort);
- FlushEvents(mouseDown+mouseUp, 0);
-
- CloseTheWindow((ExtendedWindowDataHandle)theData);
- }
-
- void DrawTheAboutMSGWindow(WindowDataHandle theData)
- {
- short h, w, i;
- Rect sourceRect, destRect;
- GrafPtr curPort;
-
- gAboutPict=DrawThePicture(gAboutPict, ((**theData).windowDepth>2) ? 128 : 129, 0, 0);
- if (gAboutPict==0L)
- return;
-
- h=(**gAboutPict).picFrame.bottom-(**gAboutPict).picFrame.top;
- w=(**gAboutPict).picFrame.right-(**gAboutPict).picFrame.left;
- GetPort(&curPort);
-
- SetRect(&sourceRect, 0, 0, w, 1);
- SetRect(&destRect, 0, 2*h-2, w, 2*h-1);
- for (i=0; i<h; i++)
- {
- CopyBits(&(curPort->portBits), &(curPort->portBits), &sourceRect, &destRect, 0, 0L);
- sourceRect.top++;
- sourceRect.bottom++;
- destRect.top--;
- destRect.bottom--;
- }
- }
-